//
//  DeliveryRecordCell.m
//  FactorySale
//
//  Created by 主事丫环HU on 2020/5/19.
//  Copyright © 2020 主事丫环. All rights reserved.
//

#import "DeliveryRecordCell.h"
@interface DeliveryRecordCell()
@property (weak, nonatomic) IBOutlet UILabel *orderNumberLabel;
@property (weak, nonatomic) IBOutlet UIButton *statusButton;
@property (weak, nonatomic) IBOutlet UILabel *nameLabel;
@property (weak, nonatomic) IBOutlet UIButton *phoneButton;
@property (weak, nonatomic) IBOutlet UILabel *timeLabel;
@property (weak, nonatomic) IBOutlet UILabel *totalMoneyLabel;
@property (weak, nonatomic) IBOutlet UIView *payedBgView;
@property (weak, nonatomic) IBOutlet UIView *notPayBgView;

@end
@implementation DeliveryRecordCell

- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
}
+ (instancetype)cellWithTableView:(UITableView *)tableView {
    
    static NSString *ID = @"DeliveryRecordCell";
    
    DeliveryRecordCell *cell = [tableView dequeueReusableCellWithIdentifier:ID];
    if (cell == nil) {
        
        cell = [NSBundle.mainBundle loadNibNamed:NSStringFromClass([self class]) owner:nil options:nil].firstObject;
    }
    cell.selectionStyle = UITableViewCellSelectionStyleNone;
    return cell;
}
- (void)setModel:(DeliveryRecordModel *)model{
    self.orderNumberLabel.text = [NSString stringWithFormat:@"订单编号:%@",model.id];
    self.nameLabel.text = model.name;
    [self.phoneButton setTitle:model.phone forState:UIControlStateNormal];
    self.timeLabel.text = model.create_time;
    self.totalMoneyLabel.text = [NSString stringWithFormat:@"¥%@",model.total_amount];
    if ([model.is_pay isEqualToString:@"0"]) {//是否付款0 否1 是
        [self.statusButton setImage:[UIImage imageNamed:@"未付款"] forState:UIControlStateNormal];
        self.payedBgView.hidden = YES;
        self.notPayBgView.hidden = NO;
    } else {
        [self.statusButton setImage:[UIImage imageNamed:@"已付款"] forState:UIControlStateNormal];
        self.payedBgView.hidden = NO;
        self.notPayBgView.hidden = YES;
    }
}
- (IBAction)phoneButtonClick:(UIButton *)sender {
    
    if (![self.phoneButton.titleLabel.text isEqualToString:@""]) {
        [HFTools callMobilePhone:self.phoneButton.titleLabel.text];
    }
}
- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
